import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
import UInfo from "../components/uinfo.vue";
// import Rg from "../components/rg.vue";
import Kg from "@/components/knowledge.vue";
import FunSwitch from "../components/funswitch.vue";
import Adm from "@/views/admin.vue";
import Result from "@/views/result.vue";
import Login from "@/components/login.vue";
import Check from "@/components/check.vue";
import AdminEdit from "@/components/adminedit.vue";
import Message from "@/components/message.vue";
import LunTan from "@/views/luntan.vue"
import Luntanmain from "@/views/luntanmain.vue"


const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter);
// const originalPush = VueRouter.prototype.push
// VueRouter.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch(err => err)
// }

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home
  },
  {
    path: "/res",
    name: "Result",
    component: Result
  },
  {
    path: "/login",
    name: "Login",
    component: Login
  },
  {
    path: "/luntan",
    name: "Luntan",
    component: LunTan,
    children: [
      {
        path: '/',
        component: Luntanmain
      },{
        path: "/luntanmain",
        name: "Luntanmain",
        component: Luntanmain
      },
    ]
  },
  
  {
    path: "/404",
    name: "404",
    component: () => import("@/views/error/404"),
    meta: { title: "404-NotFound" },
  },
 
  // {
  //   path: "/rg",
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   // component: () =>
  //   //   import(/* webpackChunkName: "about" */ "../views/About.vue")
  //   component: Rg
  // },
  // {
  //   path:"/fs",
  //   component: FunSwitch
  // },
  {
    path: "/adm",
    component: Adm,
    children: [
      {
        path: '',
        component: UInfo
      },
      {
        path: 'fs',
        component: FunSwitch
      },
      {
        path: 'uinfo',
        component: UInfo
      },
      // {
      //   path: 'rg',
      //   component: Rg
      // },
      {
        path: 'kg',
        component: Kg
      },
      {
        path: 'check',
        component: Check
      },
      {
        path: 'edit',
        component: AdminEdit
      },
      {
        path: 'message',
        component: Message
      }
    ]

  },

  {
    path: "*",
    redirect: "/404",
    hidden: true,
  },
];

const router = new VueRouter({
  mode: "history",
  // base: process.env.BASE_URL,
  routes
});




export default router;
